package com.seocoo.worker.order.widget.adapter;

import android.text.TextUtils;
import android.widget.ImageView;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.seocoo.worker.R;
import com.seocoo.worker.base.ImageLoaderEngine;
import com.seocoo.worker.order.entity.Edict;
import com.seocoo.worker.order.entity.RspGoodsMeasureInfo;

/**
 * 录入测量信息
 */
public class OrderGoldMeasureAdapter extends BaseQuickAdapter<RspGoodsMeasureInfo, BaseViewHolder> {

    public OrderGoldMeasureAdapter() {
        super(R.layout.order_gold_measure_item);
    }

    @Override
    protected void convert(BaseViewHolder helper, RspGoodsMeasureInfo item) {
        //营销方式1-用户推荐 2-折扣商品 3-平台推荐
        String sellType = "";
        String itemSellType = item.getSellType();
        if (TextUtils.equals(itemSellType, "1")) {
            sellType = "用户推荐";
        }
        if (TextUtils.equals(itemSellType, "2")) {
            sellType = "折扣商品";
        }
        if (TextUtils.equals(itemSellType, "3")) {
            sellType = "平台推荐";
        }
        helper.setText(R.id.tv_cargo_name, item.getGoodsName()).setText(R.id.tv_platform_recommend, sellType);
        ImageView view = helper.getView(R.id.iv_cargo_logo);
        new ImageLoaderEngine(item.getCoverUrl()).into(view);
        helper.addOnClickListener(R.id.tv_door_color1).addOnClickListener(R.id.tv_door_color2).addOnClickListener(R.id.tv_select_glass_color);
        String insideColor = item.getInsideColor();
        if (!TextUtils.isEmpty(insideColor)) {
            helper.setText(R.id.tv_door_color1, insideColor);
        }
        String outsideColor = item.getOutsideColor();
        if (!TextUtils.isEmpty(outsideColor)) {
            helper.setText(R.id.tv_door_color2, outsideColor);
        }
        String glassSpecificationDesc = item.getGlassSpecificationDesc();
        if (!TextUtils.isEmpty(glassSpecificationDesc)) {
            helper.setText(R.id.tv_select_glass_color, glassSpecificationDesc);
        }

    }

    public void setColor1(int position, String t1) {
        RspGoodsMeasureInfo info = mData.get(position);
        info.setInsideColor(t1);
        notifyItemChanged(position, info);
    }

    public void setColor2(int position, String t2) {
        RspGoodsMeasureInfo info = mData.get(position);
        info.setOutsideColor(t2);
        notifyItemChanged(position, info);

    }

    public void setGlass(int position, Edict t3) {
        RspGoodsMeasureInfo info = mData.get(position);
        info.setGlassSpecification(t3.dictValue);
        info.setGlassSpecificationDesc(t3.dictLabel);
        notifyItemChanged(position, info);
    }


}
